//
//  LoadingView.m
//  LvXi_newVersion
//
//  Created by 王敏 on 16/9/10.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "LoadingView.h"

@interface LoadingView()

@property(nonatomic,strong)UIActivityIndicatorView * activeView;

@end

@implementation LoadingView

+(instancetype)loadingViedw{
    LoadingView * loading = [[[self class] alloc] _initWithFrame:CGRectMake(0, 0, 50, 50)];
    return loading;
}
-(id)_initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
//        self.backgroundColor = RandColor;
        [self addSubview:self.activeView];
        [self addRadius:self.height*0.5];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
//    NSLog(@"%@",NSStringFromCGRect(self.frame));
}

-(void)beginLoading{
    [self.activeView startAnimating];
}

-(void)endLoading{
    
}
-(BOOL)isAnimated{
    return self.activeView.isAnimating;
}
-(void)setRotateAngle:(CGFloat)rotateAngle{
    self.activeView.transform = CGAffineTransformMakeRotation(rotateAngle);
}
-(UIActivityIndicatorView *) activeView{
    if(_activeView == nil){
        _activeView = [[UIActivityIndicatorView alloc] initWithFrame:self.bounds];
        _activeView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
        _activeView.hidesWhenStopped = NO;
    }
    return _activeView;
}
@end
